<template>
  <div>
    <h1>添加</h1>
    <p>名称：<input type="text" v-model="form.name"></p>
    <p>价钱：<input type="text" v-model="form.price"></p>
    <p>图片：<input type="file" id="pic"></p>
    <button @click="add">添加</button>

  </div>
</template>

<script>
export default {
  name: "add_show_shop",
  data() {
    return {
      form: {'user': localStorage.getItem('userid')}
    }
  },
  methods: {
    add() {
      let formdata = new FormData()
      let pic = document.getElementById('pic').files[0]
      formdata.append('name', this.form.name)
      formdata.append('price', this.form.price)
      formdata.append('pic', pic)
      formdata.append('user',localStorage.getItem('userid'))
      this.$axios.post('suser2/', formdata)
        .then(res => {
          if (res.data.code == 200) {
            alert('添加成功')
          }
        })

    }
  }
}
</script>

<style scoped>

</style>
